<template>
	<view>
		<web-view :src="url" class="web">

		</web-view>
	</view>
</template>

<script setup>
	import {
		ref
	} from "vue";
	import {
		onLoad
	} from '@dcloudio/uni-app';
	import {
		userStore
	} from "../../store/userStore";
	import {
		CONFIG
	} from "@/utils/config.js";
	import {
		getMapDistance
	} from "../../utils/tools";
	let store = userStore()
	let url = ref("")
	onLoad((data) => {
		let type = data.type
		console.log(type)
		if (type == "1") {
			console.log(store.currentPos)
			url.value = `https://m.amap.com/navi/?dest=${store.currentPos.longitude},${store.currentPos.latitude}&destName=
			我的位置&hideRouteIcon=1&key=${CONFIG.gaode_key}&jscode=${CONFIG.gaode_skey}`
			uni.setNavigationBarTitle({
				title: "我的位置"
			})
		} else if (type == "2") {
			let lat = data.lat
			let lon = data.lon
			url.value = `https://m.amap.com/navi/?start=${store.currentPos.longitude},${store.currentPos.latitude}
				&dest=${lon},${lat}&destName=${data.name}&key=${CONFIG.gaode_key}&jscode=${CONFIG.gaode_skey}`
			uni.setNavigationBarTitle({
				title: "到" + data.name + "的路径"
			})
		}
	
	})
</script>

<style>

</style>